package com.apping.module.edittext;

import com.apping.module.R;
import com.umeng.analytics.MobclickAgent;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class CommonEditTextAtv extends Activity implements OnClickListener {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.apping_common_edittext);

		Button button = (Button) findViewById(R.id.submit);
		button.setOnClickListener(this);
	}

	public void onResume() {
		super.onResume();
		MobclickAgent.onPageStart("SplashScreen"); // 统计页面
		MobclickAgent.onResume(this); // 统计时长
	}

	public void onPause() {
		super.onPause();
		MobclickAgent.onPageEnd("SplashScreen"); // 保证 onPageEnd 在onPause
													// 之前调用,因为 onPause 中会保存信息
		MobclickAgent.onPause(this);
	}

	@Override
	public void onClick(View v) {
		EditText numberEditText = (EditText) findViewById(R.id.number);
		EditText letterEditText = (EditText) findViewById(R.id.letter);
		EditText passwordEditText = (EditText) findViewById(R.id.password);

		String num = numberEditText.getText().toString();
		String letter = letterEditText.getText().toString();
		String password = passwordEditText.getText().toString();

		if (num == null || num.trim().equals("")) {
			numberEditText.setError("please input a number");
		}

		if (letter == null || letter.trim().equals("")) {
			letterEditText.setError("please input letters");
		}

		if (password == null || password.trim().equals("")) {
			passwordEditText.setError("please input password");
		}
	}
}